package com.fafa.swing.base;


import javax.swing.*;
import java.awt.*;

/**
 * @author : fafa
 * @version V1.0
 * @Project: SwingTest
 * @Package com.fafa.swing
 * @Description: JRadioButtonDemo
 * @date Date : 2019年11月24日 16:12
 */
public class JRadioButtonDemo extends JFrame {

    public static void main(String[] args) {
        JFrame jFrame = new JFrame("单选组件示例");
        JPanel jPanel = new JPanel();
        JLabel jLabel = new JLabel("现在是那个季节：");
        JRadioButton rb1 = new JRadioButton("春");
        JRadioButton rb2 = new JRadioButton("夏");
        JRadioButton rb3 = new JRadioButton("秋");
        JRadioButton rb4 = new JRadioButton("冬");
        jLabel.setFont(new Font("楷体",Font.BOLD,16));

        //添加ButtonGroup
        ButtonGroup bg = new ButtonGroup();
        bg.add(rb1);
        bg.add(rb2);
        bg.add(rb3);
        bg.add(rb4);
        jPanel.add(jLabel);
        jPanel.add(rb1);
        jPanel.add(rb2);
        jPanel.add(rb3);
        jPanel.add(rb4);
        jFrame.add(jPanel);
        jFrame.setBounds(300,200,400,200);
        jFrame.setVisible(true);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
}
